import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const router = new VueRouter({
  routes: [
    {
      path: "/",
      component: () => import("../views/Home.vue"),
      children: [
        {
          path: "posts",
          component: () => import("../views/Home/Posts.vue")
        },
        {
          path: "add",
          component: () => import("../views/Home/Add.vue")
        },
        {
          path: "center",
          component: () => import("../views/Home/Center.vue")
        },
        {
          path: "",
          redirect: "/posts"
        }
      ]
    },
    {
      path: "/login",
      component: () => import("../views/Login.vue")
    },
    {
      path: "/register",
      component: () => import("../views/Register.vue")
    },
    {
      path: "/posts/:id",
      component: () => import("../views/Post/_id.vue")
    }
  ]
});

export default router;
